using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder;
using YB.EnterpriseLibrary.XSLTManager.Configuration;
using System.Xml.Xsl;
using System.Xml;
using System.IO;

namespace YB.EnterpriseLibrary.XSLTManager
{
    [ConfigurationNameMapper(typeof(XSLTManagerDataRetriever))]
    [CustomFactory(typeof(XSLTManagerCustomFactory))]
    public class XSLTManager
    {
        private string name;
        private string mimeType;
        private XslCompiledTransform xslt;
        private string text;

        public XSLTManager(string name, string mimeType, XslCompiledTransform xslt, string text)
        {
            this.name = name;
            this.xslt = xslt;
            this.mimeType = mimeType;
            this.text = text;
        }

        public string Name
        {
            get { return name; }
        }

        public string MimeType
        {
            get { return mimeType; }
        }

        public string Text
        {
            get { return text; }
        }

        public void Transform(XmlReader reader, XmlWriter writer)
        {
            xslt.Transform(reader, writer);
        }

        public void Transform(XmlReader reader, XsltArgumentList arguments, XmlWriter writer) 
        {
            xslt.Transform(reader, arguments, writer);
        }

        public void Transform(XmlReader reader, XsltArgumentList arguments, Stream stream)
        {
            xslt.Transform(reader, arguments, stream);
        }

        public void Transform(XmlReader reader, Stream outputStream)
        {
            xslt.Transform(reader, null, outputStream);
        }

    }
}
